import { UserProfiles } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            //积分 鸡腿数
            coin: 99,
            headImg: require('../../assets/img/userImg.f8bbec5e.png'),
            nickName: "帅哥/美女",
        },
        cartTotal: 18,
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo;
            state.cartTotal = payload.cartTotal;
        },
        initUserInfo(state) {
            // console.log("初始化信息了....");
            state.userInfo = {
                //昵称
                nickName: '帅哥/美女',
                //积分 鸡腿数
                coin: 99,
                //头像
                headImg: require('../../assets/img/userImg.f8bbec5e.png')
            }
            state.cartTotal = 18;
        }
    },
    actions: {
        async asyncChangeUserInfo(context) {
            let user = await UserProfiles();
            context.commit("changeUserInfo", user.data.data);
        }
    }
}